import 'package:dmz/base/widget/defult_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../../base/pageWidget/base_stateful_widget.dart';
import '../controller/seting_main_controller.dart';

// ignore: must_be_immutable
class ChangeLanguage extends BaseStatefulWidget<SetingMainController> {
  ChangeLanguage({super.key});

  @override
  String titleString() => '多语言切换'.tr;

  @override
  get updateId => 'language';

  @override
  bool delectControll() => false;

  List<String> titles = ['English', '简体中文', 'แบบไทย'];

  @override
  Widget buildContent(BuildContext context) {
    return Column(
        children: List.generate(
            titles.length,
            (index) => item(titles[index], controller.getSelectIndex() == index,
                    hitLine: index == 0)
                .addGestureDetector(() => controller.changeLanguaged(index))));
  }

  Widget item(String title, bool select, {bool hitLine = false}) {
    return Container(
        color: const Color(0xFF434650),
        child: Column(mainAxisSize: MainAxisSize.min, children: [
          Container(
              height: 2.sp,
              color: hitLine ? Colors.transparent : const Color(0xFFD8D8D8)),
          DefaultText(title, 40.sp,
                  textColor: select
                      ? const Color(0xFF4CCD2C)
                      : const Color(0xFFF9F9F9))
              .marginOnly(top: 48.sp, bottom: 48.sp),
        ]));
  }
}
